$(document).ready(function(){
	
	//$('eamineeId').unbind('scroll');
	
	$.ajax({
		type:'GET',
		cache:false,
		url:rootPath+"/getVolunteer",
		async:false,
		success:function(result)
		{
			var starlTime = result.extend.volunteer[0].starlTime;
			var endTime = result.extend.volunteer[0].endTime;
			var starlTimeDate = new Date(starlTime);
			var endTimeDate = new Date(endTime);
			
			var starlTimeDateString = starlTimeDate.getFullYear() + "年" + (starlTimeDate.getMonth()+1) + "月" + starlTimeDate.getDate() + "日";
			var endTimeDateString = endTimeDate.getFullYear() + "年" + (endTimeDate.getMonth()+1) + "月" + endTimeDate.getDate() + "日";
			
			var signUpTime = starlTimeDateString + "至" + endTimeDateString;
			document.getElementById("signUpTime").innerHTML = signUpTime;
		}
	});
});

function ok()
{
	var cardId = document.getElementById("cardId").value;//身份证
	var eamineeId = document.getElementById("eamineeId").value;//考号
	
	if((/(^\d{17}([0-9]|X|x)$)/.test(cardId)))
	{
		if((/(^(1)(8)(2)(2)\d{10}$)/.test(eamineeId)))
		{
			passByValue(cardId,eamineeId);
		}
		else
			alert("考生号错误");
	}
	else
		alert("身份证错误");
}

function passByValue(cardId,eamineeId)
{	
	$.ajax({
		type:'GET',
		cache:false,
		url:rootPath+"/verifyStudent",
		async:true,
		data:{
			cardId:cardId,
			eamineeId:eamineeId
		},
		success:function(result)
		{
			if(result.code == 100)
			{
				var id = result.extend.Id;
				window.sessionStorage.setItem("student_id", id);
				passByValue2(id);
			}
			else
			{
				alert(result.extend.code);
			}
		}
	});
}

function passByValue2(student_id)
{
	$.ajax({
		type: 'GET',
		url: rootPath + "/getStudentById",
		async: true,
		data: {
			StudentId: student_id
		},
		success: function (result)
		{
			var nation = result.extend.student.nation;
			var testType = result.extend.student.testType;
			var mailingAddress = result.extend.student.mailingAddress;
			
			if(!nation || nation=="")
				window.location.href = "messageMessFill.html";
			else if(!testType || testType=="")
				window.location.href = "volunteerMessFill.html";
			else if(!mailingAddress || mailingAddress=="")
				window.location.href = "siteMessFill.html";
			else
				window.location.href = "affirmMess.html";
		}
	});
}

